﻿
Imports System.IO
Imports xmlctrl
Imports xhtmlctrl
Imports webctrl

Public Class colorli
    Inherits li

    Private Shared ReadOnly _originalColor As color = xhtmlctrl.color.windowframe
    '#daeef4
    Private Shared ReadOnly _mouseonColor As color = New color("e0f2ee")
    Private inlineScript As inlineScript = Nothing

    Public Property originalColor() As color
        Get
            Return _originalColor
        End Get
        Set(ByVal value As color)
            copy(_originalColor, value)
            colorfulControl.invoke(inlineScript, Me, originalColor(), mouseonColor())
        End Set
    End Property

    Public Property mouseonColor() As color
        Get
            Return _mouseonColor
        End Get
        Set(ByVal value As color)
            copy(_mouseonColor, value)
            colorfulControl.invoke(inlineScript, Me, originalColor(), mouseonColor())
        End Set
    End Property

#If RETIRED Then
    Private Function operateinvoke(Optional ByVal color As String = Nothing) As String
        Return operate.invoke(inlineScript, "style.backgroundColor", _
                              "this", "'" + color + "'", , "bgc") + ";"
    End Function
#End If

    Public Sub New(ByVal inlineScript As inlineScript, Optional ByVal buff As Stream = Nothing)
        MyBase.New(buff)
        Me.inlineScript = inlineScript
#If RETIRED Then
        'register javascript before render
        operateinvoke()
#End If
        colorfulControl.invoke(inlineScript, Me, originalColor(), mouseonColor())
    End Sub

    Public Sub New(ByVal page As xhtmlpage, Optional ByVal buff As Stream = Nothing)
        Me.New(page.inlineScript(), buff)
    End Sub

#If RETIRED Then
    Protected Overrides Function render(ByVal compress As Boolean) As Boolean
        style = "background:" + Convert.ToString(originalColor) + ";"
        onmouseover = operateinvoke(Convert.ToString(mouseonColor))
        onmouseout = operateinvoke(Convert.ToString(originalColor))
        Return MyBase.render(compress)
    End Function
#End If
End Class
